home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / perl5 / autouse.z / autouse
Encoding:
Text File  |  1998-10-30  |  3.5 KB  |  133 lines

  1.  
  2.  
  3.  
  4. aaaauuuuttttoooouuuusssseeee((((3333))))                                                          aaaauuuuttttoooouuuusssseeee((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      autouse - postpone load of modules until a function is used
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.        use autouse 'Carp' => qw(carp croak);
  13.        carp "this carp was predeclared and autoused ";
  14.  
  15.  
  16. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  17.      If the module Module is already loaded, then the declaration
  18.  
  19.        use autouse 'Module' => qw(func1 func2($;$) Module::func3);
  20.  
  21.      is equivalent to
  22.  
  23.        use Module qw(func1 func2);
  24.  
  25.      if Module defines _f_u_n_c_2() with prototype ($;$), and _f_u_n_c_1() and _f_u_n_c_3()
  26.      have no prototypes.  (At least if Module uses Exporter's import,
  27.      otherwise it is a fatal error.)
  28.  
  29.      If the module Module is not loaded yet, then the above declaration
  30.      declares functions _f_u_n_c_1() and _f_u_n_c_2() in the current package, and
  31.      declares a function _M_o_d_u_l_e::_f_u_n_c_3().  When these functions are called,
  32.      they load the package Module if needed, and substitute themselves with
  33.      the correct definitions.
  34.  
  35. WWWWAAAARRRRNNNNIIIINNNNGGGG
  36.      Using autouse will move important steps of your program's execution from
  37.      compile time to runtime.  This can
  38.  
  39.      +o    Break the execution of your program if the module you autoused has
  40.           some initialization which it expects to be done early.
  41.  
  42.      +o    hide bugs in your code since important checks (like correctness of
  43.           prototypes) is moved from compile time to runtime.  In particular,
  44.           if the prototype you specified on autouse line is wrong, you will
  45.           not find it out until the corresponding function is executed.  This
  46.           will be very unfortunate for functions which are not always called
  47.           (note that for such functions autouseing gives biggest win, for a
  48.           workaround see below).
  49.  
  50.      To alleviate the second problem (partially) it is advised to write your
  51.      scripts like this:
  52.  
  53.        use Module;
  54.        use autouse Module => qw(carp($) croak(&$));
  55.        carp "this carp was predeclared and autoused ";
  56.  
  57.      The first line ensures that the errors in your argument specification are
  58.      found early.  When you ship your application you should comment out the
  59.      first line, since it makes the second one useless.
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. aaaauuuuttttoooouuuusssseeee((((3333))))                                                          aaaauuuuttttoooouuuusssseeee((((3333))))
  71.  
  72.  
  73.  
  74. BBBBUUUUGGGGSSSS
  75.      If _M_o_d_u_l_e::_f_u_n_c_3() is autoused, and the module is loaded between the
  76.      autouse directive and a call to _M_o_d_u_l_e::_f_u_n_c_3(), warnings about
  77.      redefinition would appear if warnings are enabled.
  78.  
  79.      If _M_o_d_u_l_e::_f_u_n_c_3() is autoused, warnings are disabled when loading the
  80.      module via autoused functions.
  81.  
  82. AAAAUUUUTTTTHHHHOOOORRRR
  83.      Ilya Zakharevich (ilya@math.ohio-state.edu)
  84.  
  85. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  86.      _p_e_r_l(1).
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.